package day1_12.FirstPhase;

import java.util.Random;

public class RandomArray {
    public static void main(String[] args) {
        // 使用随机数打乱数组
        int[] arr = {1,2,3,4,5};
        Random rand = new Random();
        for (int i = 0; i < arr.length; i++) {
            // 获取随机索引
            int randIndex = rand.nextInt(arr.length);
            int temp = arr[i];
            arr[i] = arr[randIndex];
            arr[randIndex] = temp;
        }
        for (int i = 0; i < arr.length; i++) {
            System.out.println(arr[i]+" ");
        }
    }

}
